%@ page contentType="application/pdf;charset=UTF-8"%>
<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%

 File reportFile = new File(this.getServletContext().
getRealPath("/reports/sysutil.jasper"));
 
 String url="jdbc:oracle:thin:@oracle.students.itee.uq.edu.au:1521:iteeo";
 Class.forName("oracle.jdbc.driver.OracleDriver");
 Map parameters = new HashMap();

 parameters.put("sysutil",
 "select Username, nvl(Email, '-'), nvl(FName, '-'), nvl(LName, '-'), Accessibility, CreateTime, nvl(ExpireDate, to_date('31-12-2099', 'DD-MM-YYYY')) FROM PollUser order by accessibility desc, username asc");
 Connection conn = DriverManager.getConnection(url,
"csse3004ge", "967431");
 
 byte[] bytes=JasperRunManager.
runReportToPdf(reportFile.getPath(),parameters,conn);
 
 response.setContentType("application/pdf");
 response.setContentLength(bytes.length);
 
 ServletOutputStream outStream = response.getOutputStream();
 outStream.write(bytes,0,bytes.length);
 outStream.flush();
 outStream.close();
 out.clear();
 out = pageContext.pushBody();
%>